package LinkedListPackage;

/**
 * @author Lzm
 * @version 1.0
 */
public class removeElements_ {
  public ListNode removeElements(ListNode head, int val) {
    if (head == null){
      return null;
    }
    ListNode dummyHead = new ListNode();
    dummyHead.next = head;
    ListNode temp = dummyHead;
    while(temp.next != null){
      if (temp.next.val == val){
        temp.next = temp.next.next;
      }
      temp = temp.next;
    }
    return dummyHead.next;
  }
}
